/*
 *  Copyright (c) 2011 Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the GNU Lesser Public License v2.1
 *  which accompanies this distribution, and is available at
 *  http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 *
 *  Contributors:
 *      Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany - RMI Server and wrapper
 */
package de.ipk_gatersleben.bit.bi.edal.rmi.server;

import java.io.Serializable;
import java.security.Principal;

import javax.security.auth.Subject;

/**
 * Container to hold all necessary authentication token, i.e. login and password
 * 
 * @author arendd
 */
public final class Authentication implements Serializable {

	private Subject subject = null;

	private static final long serialVersionUID = 1L;

	private String name;
	private String password;

	public Authentication(Subject subject) {
		this.subject = subject;
	}

	/**
	 * @return the login name
	 */
	public String getName() {

		for (Principal principal : this.subject.getPrincipals()) {
			this.name = principal.getName();
		}

		return this.name;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {

		return this.password;
	}

	/**
	 * @return the subject
	 */
	public Subject getSubject() {
		return subject;
	}

}
